package com.noredister;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;

/**
 * 这个Servlet并没有使用注解声明也没有在xml声明
 */
public class MyServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=UTF-8");
        PrintWriter writer = resp.getWriter();
        writer.println("动态注册Servlet成功！ <br>");

        Enumeration<String> initParameterNames = this.getInitParameterNames();
        String name = initParameterNames.nextElement();
        while (name != null) {
            String value = this.getInitParameter(name);
            writer.println(name + " = " + value + "<br>");
            initParameterNames.nextElement();
        }
    }
}
